<include file="Public/head"/>
<!-- <link href="__PUBLIC__/qwadmin/layui/layui.css" rel="stylesheet" type="text/css" /> -->
<!-- <link href="__PUBLIC__/qwadmin/css/shen/shen.css" rel="stylesheet" type="text/css" /> -->
<!-- <link rel="stylesheet" href="__PUBLIC__/qwadmin/css/bootstrap.css"/> -->
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <style type="text/css">
        body .demo-class .layui-layer-title{background:#6495ED; color:#fff; border: none;}
        body .demo-class .layui-layer-btn{border-top:1px solid #E9E7E7}
        body .demo-class .layui-layer-btn a{background:#333;}
        body .demo-class .layui-layer-btn .layui-layer-btn1{background:#999;}
        /*table{border: 1px;}*/
        tr{border: none;}
        .div1{display: flex;flex-direction: row;justify-content: center;align-items: flex-start;margin-top: 20px; margin-bottom: 20px;}
        .put1{width: 10%;height: 80%;border: none;}
        .put{border: none;width: 100%;height: 80%;text-align: center;}
        td{height: 40px;border-bottom: 0px;border-right: 0px;}
        th{height: 40px;border-bottom: 0px;border-right: 0px;}
        .td button{
            margin-left: :50%;
        }
        #ban{
            width:75%;
            margin:60px auto;
            border: 1px solid #ccc;
            /*padding: 0 -1000px;*/
            box-shadow: 5px 5px 30px #888888;
        }
        #ban table{
            width:90%;
            margin:60px auto;
        }
        #zhao{
            width:75%;
            margin:60px auto;
            border: 1px solid #ccc;
            /*padding: 0 -1000px;*/
            box-shadow: 5px 5px 30px #888888;
        }
        #zhao table{
            width:90%;
            margin:60px auto;
        }
        #lao{
            width:75%;
            margin:60px auto;
            border: 1px solid #ccc;
            /*padding: 0 -1000px;*/
            box-shadow: 5px 5px 30px #888888;
        }
        #lao table{
            width:90%;
            margin:60px auto;
        }
        #xuanxiang button{
            margin:30px 30px;
            width:100px;
            height:50px;
        }
        #xuanxiang{
            width:500px;
            border:1px solid #ccc;
            box-shadow: 10px 10px 5px #888888;
            position: absolute;
            margin:10% 30%;
            /*padding:20px auto;*/
        }
     /*   #gxuanxiang button{
            margin:30px 20px;
            width:100px;
            height:50px;
        }*/
    </style>
    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>
                   
                    <div class="container-fluid">
                      <div class="row">
                            <form class="form-inline" >
                                <!-- <a class="btn btn-info" href="{:U('add')}" value="">新增</a> -->
                                <label class="inline"><b style="font-size:17px;">申请类别选择:</b></label>&nbsp
                                <select name="field" class="form-control" style="width:15%;" id="select">
                                    <!-- <option>请选择...</option> -->
                                    <option>办公用品领用</option>
                                    <option>劳保用品领用</option>
                                    <option>招待用品领用</option>
                                    <!-- <option >急性物资</option> -->
                                    <!-- <option></option> -->
                                </select>
                                
                               <!--  <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    Search
                                </button> -->
                            </form>
                        </div>
                    </div>

                    
                    

                    <div id="ban" style="">
                            <h2 style="text-align:center;">办公用品申请</h2>
                            <div class="row" style="margin:0px 20px;">
                            <form class="form-inline"  id="formId">
                               
                                <label class="inline">物品搜索:</label>
                                
                                <input type="text" name="wname" class="form-control">
                                <input type="hidden" name="x_type" value="1" class="form-control">
                               
                                <div  class="btn btn-purple btn-sm" onclick="bsou()">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    Search
                                </div>
                                 <div class='btn btn-info' id='bfan' style='width:100px;height:30px;line-height:10px;display:none;'>返回上一级</div>
                                 <div class='btn btn-info' id='bfen' style='width:120px;height:30px;line-height:10px;'>返回选择</div>
                            </form>

                        </div>
                            <table class="table table-bordered" id="tet" >
                                <tr>
                                    <th class="center">编号</th>
                                    <th class="center">物品名称</th>
                                    <th class="center">库存</th>
                                    <th class="center">单价</th>
                                    <th class="center">申请数量</th>
                                    <th class="center">操作</th>

                                </tr>
                                <volist name="blist" id="vo">
                                <tr id="tr">
                                    <td class="center">{$vo.id}</td>
                                    <td class="center">{$vo.name}</td>
                                    <td class="center">{$vo.number}/{$vo.com}</td>
                                    <!-- <td class="center" style="display:none">{$vo.number}</td> -->
                                    <!-- <td class="center" style="display:none"><input type="hidden" name="x_type" value="{$vo.x_type}"></td> -->
                                    <!-- <td class="center" style="display:none"><input type="hidden" name="unit" value="{$vo.unit}"></td> -->
                                    <td class="center">{$vo.unit}/元</td>
                                    <td class="center" style="display:none"><input type="hidden" name="type" value="0"></td>
                                    <td class="center"><input type="text" style="width:50px;">/{$vo.com}</td>
                                    <td class="center"><button class="btn-info" onclick="shen({$vo.id},this)">申请</button></td>


                                </tr>




                            </volist> 
                            </table>
                                          
                          


                    </div>  


<!-- ---------------------------行政劳保用品表单------------------------------ -->
    <div id="lao" style="display:none;">
        <h2 style="text-align:center;">劳保用品申请</h2>
        <div class="row" style="margin:0px 20px;">
            <form class="form-inline"  id="formIdl">                              
                <label class="inline">物品搜索:</label>
                <input type="text" name="wname" class="form-control">
                <input type="hidden" name="x_type" value="2" class="form-control">
                <div  class="btn btn-purple btn-sm" onclick="lsou()">
                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                        Search
                </div>
                <div class='btn btn-info' id='lfan' style='width:100px;height:30px;line-height:10px;display:none;'>返回上一级</div>
                <div class='btn btn-info' id='lfen' style='width:120px;height:30px;line-height:10px;'>返回选择</div>
            </form>

        </div>
            <table class="table table-bordered" id="ltet" >
                <tr>
                    <th class="center">编号</th>
                    <th class="center">物品名称</th>
                    <th class="center">库存</th>
                    <th class="center">单价</th>
                    <th class="center">申请数量</th>
                    <th class="center">操作</th>

                </tr>
                <volist name="llist" id="lvo">
                <tr id="trl">
                    <td class="center">{$lvo.id}</td>
                    <td class="center">{$lvo.name}</td>
                    <td class="center">{$lvo.number}/{$lvo.com}</td>
                    <td class="center" style="display:none">{$lvo.number}</td>
                    <td class="center" style="display:none"><input type="hidden" name="x_type" value="{$lvo.x_type}"></td>
                    <td class="center" style="display:none"><input type="hidden" name="unit" value="{$lvo.unit}"></td>
                    <td class="center">{$lvo.unit}/元</td>
                    <td class="center" style="display:none"><input type="hidden" name="type" value="0"></td>
                    <td class="center"><input type="text" style="width:50px;">/{$lvo.com}</td>
                    <td class="center"><button class="btn-info" onclick="shen({$lvo.id},this)">申请</button></td>
                    


                </tr>




            </volist> 
            </table>
    </div>  

<!-- ---------------------------行政劳保用品表单 END------------------------------ -->





<!-- ---------------------------行政招待用品表单------------------------------ -->
<div id="zhao" style="display:none;">
       <h2 style="text-align:center;">招待用品申请</h2>
        <div class="row" style="margin:0px 20px;">
            <form class="form-inline"  id="formIdz">                              
                <label class="inline">物品搜索:</label>
                <input type="text" name="wname" class="form-control">
                <input type="hidden" name="x_type" value="3" class="form-control">
                <div  class="btn btn-purple btn-sm" onclick="zsou()">
                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                        Search
                </div>
                <div class='btn btn-info' id='zfan' style='width:100px;height:30px;line-height:10px;display:none;'>返回上一级</div>
                <div class='btn btn-info' id='zfen' style='width:120px;height:30px;line-height:10px;'>返回选择</div>
            </form>

        </div>
        <table class="table table-bordered" id="ztet" >
            <tr>
                <th class="center">编号</th>
                <th class="center">物品名称</th>
                <th class="center">库存</th>
                <th class="center">单价</th>
                <th class="center">申请数量</th>
                <th class="center">操作</th>

            </tr>
            <volist name="zlist" id="zvo">
            <tr id="trz">
                <td class="center">{$zvo.id}</td>
                <td class="center">{$zvo.name}</td>
                <td class="center">{$zvo.number}/{$zvo.com}</td>
                <td class="center" style="display:none">{$zvo.number}</td>
                <td class="center" style="display:none"><input type="hidden" name="x_type" value="{$zvo.x_type}"></td>
                <td class="center" style="display:none"><input type="hidden" name="unit" value="{$zvo.unit}"></td>
                <td class="center">{$zvo.unit}/元</td>
                <td class="center" style="display:none"><input type="hidden" name="type" value="0"></td>
                <td class="center"><input type="text" style="width:50px;">/{$zvo.com}</td>
                <td class="center"><button class="btn-info" onclick="shen({$zvo.id},this)">申请</button></td>
            
            </tr>




        </volist> 
        </table>
</div>  

<!-- ---------------------------行政招待用品表单 END------------------------------ -->













<!-- 
                    <div id="xuanxiang" style="display:none;">
                        <button class="btn-info" onclick="ban()">办公用品申请</button>
                        <button class="btn-warning" onclick="lao()">劳保用品申请</button>
                        <button class="btn-success" onclick="zhao()">招待用品申请</button>
                        
                    </div> -->




            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<script src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/jquery-1.7.2.min.js"></script>
<script src="__PUBLIC__/js/jHsDate.js"></script>
<!-- inline scripts related to this page -->
<script>
    //给下拉框设置事件
    $("select").change(function(){
        
        var name = this.value;
        // console.log(name);
        if (name == '劳保用品领用') {
            // $("#jixing").css("display",'flex');
            $("#lao").show(500);
            $("#ban").hide();
            $("#zhao").hide();
        }else{
           if (name == '招待用品领用') {
                $("#lao").hide();
                $("#ban").hide();
                $("#zhao").show(500);
           }else{
                if (name == '办公用品领用') {
                    $("#lao").hide();
                    $("#ban").show(500);
                    $("#zhao").hide();
                }
           }
           
             
           
        }
    })

    //显示办公用品 ,隐藏分类
    function ban()
    {
        $("#ban").show();
        $("#xuanxiang").css("display",'none');

    }

    //显示劳保用品 ,隐藏分类
    function lao()
    {
        $("#lao").show();
        $("#xuanxiang").css("display",'none');

    }

    //显示招待用品 ,隐藏分类
    function zhao()
    {
        $("#zhao").show();
        $("#xuanxiang").css("display",'none');

    }

    //办公用品返回分类选择 
    $('#bfen').click(function(){
         history.go(0);
         // $("#lao").show(); 
    })

    //劳保用品返回分类选择 
    $('#lfen').click(function(){
         history.go(0); 
    })
    //招待用品返回分类选择 
    $('#zfen').click(function(){
         history.go(0); 
    })
    //办公用品搜索
    function bsou()
    {
       
        $.ajax({
            type: "POST",
            url:"{:U('Shen/sou')}",
            data:$('#formId').serialize(),// 要提交的表单 
            success: function(data) {
                
                 if (data != 1111) {
                    $('td').remove();
                        
                    for (var i = 0; i < data.length; i++) {
                        // console.log(data);
                        $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"/"+data[i].com+"</td><td class='center'>"+data[i].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#tet');
                        $('#bfan').show();
                        $('#bfen').hide();
                    }
                    //  for (index in data) {
                    //     // $("#uid"+data[index].id).text(data[index].number);
                    //     // console.log(data[index].id);
                    //     $("<td class='center'>"+data[index].id+"</td><td class='center'>"+data[index].name+"</td><td class='center'>"+data[index].number+"/"+data[index].com+"</td><td class='center'>"+data[index].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[index].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[index].id+",this)'>申请</button></td>").appendTo('#tr');
                    //     // $("<div class='btn btn-info' id='fan' style='width:50px;'>返回</div>").appendTo('#formId');
                    //     $('#bfan').show();
                    //     $('#bfen').hide();
                    // }
                    
               }else{
                    $('td').remove();
                    $("<td class='center' colspan='6' id='bmei'><h2>没有搜索到!!!</h2></td>").appendTo('#tr');
                    $('#bfan').show();
                    $('#bfen').hide();
               }
               
              
            }
        });
    }


    //劳保用品搜索
    function lsou()
    {
       
        $.ajax({
            type: "POST",
            url:"{:U('Shen/sou')}",
            data:$('#formIdl').serialize(),// 要提交的表单 
            success: function(data) {
                
                 if (data != 1111) {
                    $('td').remove();
                    for (var i = 0; i < data.length; i++) {
                        // console.log(data);
                        $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"/"+data[i].com+"</td><td class='center'>"+data[i].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#ltet');
                        $('#lfan').show();
                        $('#lfen').hide();
                    }
                    //  for (index in data) {
                    //     // $("#uid"+data[index].id).text(data[index].number);
                    //     // console.log(data[index].id);
                    //     $("<td class='center'>"+data[index].id+"</td><td class='center'>"+data[index].name+"</td><td class='center'>"+data[index].number+"/"+data[index].com+"</td><td class='center'>"+data[index].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[index].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[index].id+",this)'>申请</button></td>").appendTo('#trl');
                    //     // $("<div class='btn btn-info' id='fan' style='width:50px;'>返回</div>").appendTo('#formId');
                    //     $('#lfan').show();
                    // }
                    
               }else{
                    $('td').remove();
                    $("<td class='center' colspan='6' id='lmei'><h2>没有搜索到!!!</h2></td>").appendTo('#trl');
                    $('#lfan').show();
                    $('#lfen').hide();
               }
               
              
            }
        });
    }
    //招待用品搜索
    function zsou()
    {
       
        $.ajax({
            type: "POST",
            url:"{:U('Shen/sou')}",
            data:$('#formIdz').serialize(),// 要提交的表单 
            success: function(data) {
                
                 if (data != 1111) {
                    $('td').remove();
                    for (var i = 0; i < data.length; i++) {
                        // console.log(data);
                        $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"/"+data[i].com+"</td><td class='center'>"+data[i].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#ztet');
                        $('#zfan').show();
                        $('#zfen').hide();
                    }
                    //  for (index in data) {
                    //     // $("#uid"+data[index].id).text(data[index].number);
                    //     // console.log(data[index].id);
                    //     $("<td class='center'>"+data[index].id+"</td><td class='center'>"+data[index].name+"</td><td class='center'>"+data[index].number+"/"+data[index].com+"</td><td class='center'>"+data[index].unit+"/元</td><td class='center'><input type='text' style='width:50px;'>/"+data[index].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[index].id+",this)'>申请</button></td>").appendTo('#trz');
                    //     // $("<div class='btn btn-info' id='fan' style='width:50px;'>返回</div>").appendTo('#formId');
                    //     $('#zfan').show();
                    // }
                    
               }else{
                    $('td').remove();
                    $("<td class='center' colspan='6' id='zmei'><h2>没有搜索到!!!</h2></td>").appendTo('#trz');
                    $('#zfan').show();
                    $('#zfen').hide();
               }
               
              
            }
        });
    }






    //返回所有列表
   $('#bfan').click(function(){
         $.ajax({
            type: "POST",
            url:"{:U('Shen/fan')}",
            data:{'lei':1},// 要提交的表单 
            success: function(data) {
            // console.log(data);
            for (var i = 0; i < data.length; i++) {
                // console.log(data);
                $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"</td><td class='center'>"+data[i].unit+"</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#tet');
            }
                 $('#bfan').hide();
                 $('#bmei').remove();
                 $('#bfen').show();
              
            }
        });
   })

    //返回所有列表
   $('#lfan').click(function(){
         $.ajax({
            type: "POST",
            url:"{:U('Shen/fan')}",
            data:{'lei':2},// 要提交的表单 
            success: function(data) {
            // console.log(data);
            for (var i = 0; i < data.length; i++) {
                // console.log(data);
                $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"</td><td class='center'>"+data[i].unit+"</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#ltet');
            }
                 $('#lfan').hide();
                 $('#lmei').remove();
                  $('#lfen').show();
              
            }
        });
   })

    //返回所有列表
   $('#zfan').click(function(){
         $.ajax({
            type: "POST",
            url:"{:U('Shen/fan')}",
            data:{'lei':3},// 要提交的表单 
            success: function(data) {
            // console.log(data);
            for (var i = 0; i < data.length; i++) {
                // console.log(data);
                $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].number+"</td><td class='center'>"+data[i].unit+"</td><td class='center'><input type='text' style='width:50px;'>/"+data[i].com+"</td><td class='center'><button class='btn-info' onclick='shen("+data[i].id+",this)'>申请</button></td></tr>").appendTo('#ztet');
            }
                 $('#zfan').hide();
                 $('#zmei').remove();
                  $('#zfen').show();
              
            }
        });
   })



function shen(id,obj)
{

    var num = $(obj).parent().prev().children().val();
    // console.log(num);
    var type = 0;
    // console.log(type);

     if (num == '') {
        layer.msg('可不能什么都不填哟 ');
        return false;
    }else{
    // console.log(num);
    layer.confirm('确定发起申请么,(ง •̀_•́)ง？', {
          btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                 type: "POST",
                 url:"{:U('Shen/add')}",
                 data:{"id":id,"num":num,"type":type},// 要提交的表单 
                 beforeSend:function(){
                    layer.load(0, {shade: false});
                },
                 success: function(msg) {
                    if (msg == 1111) {
                        layer.msg('已提交,请等待审批ヾ(=^▽^=)ノ', {icon: 1});
                    }else{
                        if (msg == 3333) {
                            layer.msg('您申请的数量已超过库存数量,请重新申请.');
                        }else{
                            if (msg == 2222) {layer.msg('申请失败,再来一次把ヽ(･ω･｡)ﾉ');}
                        }
                        
                    }
                 },
                 complete: function() {
                     layer.closeAll('loading');
                }
            });
         
        }, function(){
            layer.msg(' (｡・`ω´･) 再见');
        });
    }
}



</script>

</body>
</html>
